/*
 * @Descripttion:
 * @version:
 * @Author: ChenXiang
 * @Date: 2021-04-08 16:48:39
 * @LastEditors: ChenXiang
 * @LastEditTime: 2021-04-16 11:23:51
 */
import React, { Component } from "react";
import { withRouter } from "react-router";
import { Route, Redirect } from "react-router-dom";

class AuthRouter extends Component {
  render() {
    const { component: Component, ...rest } = this.props;
    const isLogged = sessionStorage.getItem("isLogin") === "1";

    return (
      <Route
        {...rest}
        render={(props) => {
          console.log("props");
          console.log(props);
          return isLogged ? (
            <Component {...props} />
          ) : (
            <Redirect to="/login" state={111} />
          );
        }}
      />
    );
  }
}

export default withRouter(AuthRouter);
